/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React from 'react';

export default class CockpitGet{
    constructor(options = {}) {
    }

    //登录接口
    mobileLogin(loginName, userPwd) {  
        return fetch(rootUrl + 'login/login!mobileLogin.action?channel=cockpit&userInfo.loginName=' + loginName + '&userInfo.userPwd=' + userPwd)
    }

    //密码修改接口
    updateMobilePwd(oldMobilePwd,newMobilePwd,userId) {
        return fetch(rootUrl + 'user/user!updateMobilePwd.action?channel=cockpit&userInfo.oldMobilePwd=' + oldMobilePwd + '&userInfo.newMobilePwd=' + newMobilePwd + '&userInfo.userId='+userId)
    }
    
    //版本更新
    versionCheck(versionNumber) {
        return fetch(rootUrl + 'version/version!latestVersionInfo.action?channel=cockpit&version.versionNumber='+versionNumber)
    }

    //获取新版本文件URL
    getVersionUrl(params) {
        return rootUrl + params;
    }
  
    //指标大类查询
    queryIndType() {
        return fetch(rootUrl + 'cockpit/cockpit-ind!queryIndType.action?channel=cockpit')
    }

    //指标小类查询
    queryIndConfigByTypeId(indTypeId) {
        return fetch(rootUrl + 'cockpit/cockpit-ind!queryIndConfigByTypeId.action?channel=cockpit&indTypeId=' + indTypeId)
    }
    
    //报表查询
    cockpitReport(params) {
        var p = "&date_grade=" + params.date_grade +
                "&date_start=" + params.date_start +
                "&date_end=" + params.date_end +
                "&org_grade=" + params.org_grade +
                "&ind_ids=" + params.ind_ids +
                "&org_ids=" + params.org_ids;
        
        return fetch(rootUrl + 'cockpit/cockpit-report!cockpitReport.action?channel=cockpit' + p)
    }

    //机构列表查询
    queryReportOrg(org_id) {
        return fetch(rootUrl + 'cockpit/cockpit-ind-user!queryReportOrg.action?channel=cockpit&org_id=' + org_id)
    }
    
    //个人的指标配置查询
    queryUserAllConfig(userid) {
        return fetch(rootUrl + 'cockpit/cockpit-ind-user!queryUserAllConfig.action?channel=cockpit&userid=' + userid)
    }
    
    //个人的指标root配置查询
    getUserCindConfigRootList(userid) {
        return fetch(rootUrl + 'cockpit/cockpit-ind-user!getUserCindConfigRootList.action?channel=cockpit&userid=' + userid)
    }

    //大类删除
    deleteUserCindConfigRoot(params) {
        return fetch(rootUrl + 'cockpit/cockpit-ind-user!deleteUserCindConfigRoot.action?channel=cockpit&config_root_id='+params.config_root_id)
    }

    //小类删除
    deleteUserCindConfig(params) {
        return fetch(rootUrl + 'cockpit/cockpit-ind-user!deleteUserCindConfig.action?channel=cockpit&config_id='+params.config_id+'&userid='+params.userid)
    }

    //大类增加
    addUserCindRootConfig(params) {
        return fetch(rootUrl + 'cockpit/cockpit-ind-user!addUserCindRootConfig.action?channel=cockpit&config_root_name='+params.config_root_name+'&userid='+params.userid)
    }

    //小类增加
    addUserCindConfig(params) {
        var p = "&userid=" + params.userid +
                "&config_root_id=" + params.config_root_id +
                "&config_name=" + params.config_name +
                "&org_grade=" + params.org_grade +
                "&ind_ids=" + params.ind_ids +
                "&date_grade=" + params.date_grade +
                "&org_ids=" + params.org_ids;
        return fetch(rootUrl + 'cockpit/cockpit-ind-user!addUserCindConfig.action?channel=cockpit'+p)
    }

    //大类名称修改
    updateUserCindRootConfig(params) {
        var p = "&config_root_id=" + params.config_root_id +
                "&config_root_name=" + params.config_root_name +
                "&userid=" + params.userid;
        return fetch(rootUrl + 'cockpit/cockpit-ind-user!updateUserCindRootConfig.action?channel=cockpit'+p)
    }

    //小类名称修改
    updateUserCindConfig(params) {
        var p = "&config_id=" + params.config_id +
                "&config_name=" + params.config_name +
                "&userid=" + params.userid;
        return fetch(rootUrl + 'cockpit/cockpit-ind-user!updateUserCindConfig.action?channel=cockpit'+p)
    }
}
